import org.springframework.context.ApplicationContext;
import org.springframework.context.support.ClassPathXmlApplicationContext;
/**
 * 可以自己写 一个 JdbcTemplate 类 但是我懒得了
 */
import org.springframework.jdbc.core.JdbcTemplate;

import java.io.Serializable;

public class Person extends JdbcTemplate implements Serializable {
    private String name;
    private int age;

    //我不提供无参构造器
    public Person(String name, int age) {
        System.out.println("反序列化，你调用我了吗？");
        this.name = name;
        this.age = age;
    }

    @Override
    public String toString() {
        return "Person{" +
                "name='" + name + '\'' +
                ", age=" + age +
                '}';
    }

    public static void main(String[] args) {
        Person person = new Person("123", 15);
        System.out.println(person.toString());

        //1.获取容器
        ApplicationContext applicationContext = new ClassPathXmlApplicationContext("bean.xml");
        //2.获取对象
        JdbcTemplate jdbcTemplate = applicationContext.getBean("jdbcTemplate", JdbcTemplate.class);
        //3.执行操作
    }
}